package com.erps.dao;

import java.util.List;
import java.util.Map;

import com.erps.CommonUtils.ActiveField;
import com.erps.CommonUtils.DateUtils;
import com.erps.CommonUtils.JActiveField;
import com.erps.CommonUtils.JActiveTable;
import com.erps.CommonUtils.Sequence;
import com.erps.CommonUtils.StringEx;
import com.erps.db.DBManager;
import com.hmkj.entity.ErspPlatArgs;

public class ErspPlatArgsDao extends JActiveTable {
	public ErspPlatArgsDao() {
		this.setDBTableName("ersp_plat_args");
		AddField(new JActiveField("id", "id", ActiveField.ftString, 36));
		setDefaultFieldValue("id", Sequence.getGuid());
		AddField(new JActiveField("arg_name", "arg_name", ActiveField.ftString, 20));
		AddField(new JActiveField("arg_value", "arg_value", ActiveField.ftString, 20));
		AddField(new JActiveField("arg_code", "arg_code", ActiveField.ftString, 36));

		AddField(new JActiveField("last_update_time", "last_update_time", ActiveField.ftLong));
		setDefaultFieldValue("last_update_time", String.valueOf(DateUtils.getDayTimeNum()));
		setDbKeyFields("id");
	}

	public int add(ErspPlatArgs vo) {
		setFieldValue("id", vo.getId());
		setFieldValue("arg_name", vo.getArg_name());
		setFieldValue("arg_value", vo.getArg_value());
		setFieldValue("arg_code", vo.getArg_code());
		return DBManager.ExecSQL(this.getSQL());
	}

	public ErspPlatArgs get(String cKeyID) {
		Map<String, String> vo = DBManager.GetRow("select * from " + this.getDBTableName() + " where id='" + cKeyID + "'");
		ErspPlatArgs obj = new ErspPlatArgs();
		obj.setId(StringEx.getMapVal(vo, "id"));
		obj.setArg_name(StringEx.getMapVal(vo, "arg_name"));
		obj.setArg_value(StringEx.getMapVal(vo, "arg_value"));
		obj.setArg_code(StringEx.getMapVal(vo, "arg_code"));
		return obj;
	}

	public String getSQL(ErspPlatArgs vo) {
		setFieldValue("id", vo.getId());
		setFieldValue("arg_name", vo.getArg_name());
		setFieldValue("arg_value", vo.getArg_value());
		setFieldValue("arg_code", vo.getArg_code());
		return this.getSQL();
	}

	public List<Map<String, String>> Query() {
		String cWhereParm = null;
		String sql = getQuerySQL(cWhereParm);
		return DBManager.QueryData(sql);
	}
}
